package de.carcophan.jimdb.gwt.client.util;

import com.google.gwt.user.client.ui.PopupPanel;

import de.carcophan.jimdb.gwt.client.ClientFactory;

public class WidgetUtil {

	private PopupPanel popupPanel;

	private ClientFactory clientFactory;

	public WidgetUtil(ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
		initAjaxLoaderDialog();
	}

	private void initAjaxLoaderDialog() {
		popupPanel = new PopupPanel();
		popupPanel.add(clientFactory.getAjaxLoadingImage());
		popupPanel.setModal(true);
	}

	public void showAjaxLoader(boolean visible) {
		if (visible) {
			popupPanel.show();
			popupPanel.center();
		} else {
			popupPanel.hide();
		}

	}

}
